/**
 * @properties={typeid:24,uuid:"951CC92B-8E92-4892-B870-C6AE931ACC71"}
 */
function onShow(firstShow, event) {
	
	controlaTipo()
	llenarVl('recepciones_oc_detalle_din')
	elements.tabs_180.enabled = false
}

/**
 * @properties={typeid:24,uuid:"BC37A289-CB41-4685-A789-740611B55476"}
 */
function llenarVl(valuelist)
{
	var query = 'SELECT c.nro_oc '+ globals.gCharConcat + '\' - \' '+ globals.gCharConcat + ' rtrim(p.descripcion) '+ globals.gCharConcat + ' \' - \' '+ globals.gCharConcat + ' o.cantidad_pendiente_entrega as "vl", d.oc_detalle_id FROM recep_detalle as "d" '+
				'join oc_detalle as "o" on d.oc_detalle_id = o.oc_detalle_id '+
				'join oc_cabecera as "c" on c.oc_cabecera_id = o.oc_cabecera_id '+
				'join productos as "p" on p.producto_id = o.producto_id '+
				'where recep_cabecera_id = ? '+
				'group by d.oc_detalle_id, o.cantidad_pendiente_entrega, p.descripcion, c.nro_oc '+
				'order by d.oc_detalle_id'
	var max 	= -1
	var args 	= [recep_cabecera_id]
	var server 	= databaseManager.getDataSourceServerName(controller.getDataSource())
	var ds 		= databaseManager.getDataSetByQuery(server,query,args,max)
	
	application.setValueListItems(valuelist,ds)	
}

/**
 * @properties={typeid:24,uuid:"8A106B38-5786-488D-B47C-C47911499AEA"}
 */
function controlaTipo()
{
	if (tipo == 0)
	{
		elements.grp_cliente.visible		= 0
		elements.grp_proveedor.visible 		= 1
		elements.tabs_180.tabIndex			= 2
	}
	else
	{
		elements.grp_cliente.visible				= 1
		elements.grp_proveedor.visible 				= 0
		elements.tabs_180.tabIndex					= 1
	}
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"233CF7EC-407A-4232-A52D-3418E86F23C5"}
 */
function imprimir(event) {
	forms.recepciones_cab_imp.controller.loadRecords(recep_cabecera_id)
	forms.recepciones_cab_imp.controller.showPrintPreview()
}

/**
 * @properties={typeid:24,uuid:"738F3752-6CAB-4839-8555-0F58E5D72C26"}
 */
function imprimirPdf()
{
	forms.recepciones_cab_imp.controller.loadRecords(recep_cabecera_id)
	globals.metodoPdf('recepciones_cab_imp', 'recepcion', false)
}
